package com.example.minefieldkeepercloud.adapter;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.example.minefieldkeepercloud.R;
import com.example.minefieldkeepercloud.activity.machineslist.MachineDetailAc;
import com.example.minefieldkeepercloud.activity.machineslist.MachineListAc;
import com.example.minefieldkeepercloud.activity.treatedmachine.TreateMachineAcDetail;
import com.example.minefieldkeepercloud.bean.DailyPowerBean;
import com.example.minefieldkeepercloud.bean.MacListBean;
import com.king.base.adapter.ViewHolderRecyclerAdapter;
import com.king.base.adapter.holder.ViewHolder;

import java.util.List;

public class MachineListAdapter extends ViewHolderRecyclerAdapter<MacListBean.DataBean> {
    private Activity context;


    public MachineListAdapter(Activity context, List<MacListBean.DataBean> listData) {
        super(context, listData);
        this.context = context;
    }


    @Override
    public View buildConvertView(LayoutInflater layoutInflater, int viewType) {
        return layoutInflater.inflate(R.layout.adapter_machinelist, null);
    }

    @Override
    public void bindViewDatas(ViewHolder holder, final MacListBean.DataBean bean, final int position) {

        holder.setText(R.id.tv_ip, bean.getIP());
        holder.setText(R.id.tv_mode, bean.getMacModelName());
        holder.setText(R.id.tv_nowsl, bean.getRelsl());
        holder.setText(R.id.tv_sl, bean.getAvgsl());
        TextView tv_state=holder.getView(R.id.tv_state);
        if(bean.getMacRunStatus().equals("离线"))
            tv_state.setVisibility(View.VISIBLE);
        else
            tv_state.setVisibility(View.GONE);

//        holder.getConvertView().setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent=new Intent(context, MachineDetailAc.class);
//                Bundle bd=new Bundle();
//                bd.putString("id",(MachineListAc)context.getFId());
//                bd.putSerializable("data",bean);
//                intent.putExtra("bd",bd);
//                context.startActivity(intent);
//
//
//            }
//        });

    }
}
